package com.studio.framework.controller.monitorSystem.controller;

import com.studio.framework.controller.monitorSystem.bean.ErrorLog;
import com.studio.framework.controller.monitorSystem.dto.ErrorLogDto;
import com.studio.framework.controller.monitorSystem.service.ErrorLogService;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @Author jujh
 * @Date 2018/7/24
 * 错误日志
 */
@Controller
public class ErrorLogController {

    @Autowired
    private ErrorLogService errorLogService;

    @RequestMapping(value = "/error-log-list")
    public ModelAndView pageJump() {
        ModelAndView mv = new ModelAndView("error-log-list");
        return mv;
    }

    @RequestMapping(value = "/error-log-list1")
    @ResponseBody
    public String findAll(ErrorLogDto errorLogDto) {
        List<ErrorLog> errorLogList = errorLogService.findAllByCondition(errorLogDto);
        JSONArray json = JSONArray.fromObject(errorLogList);
        return json.toString();
    }

    /**
     * add
     *
     * @return
     */
    @RequestMapping(value = "/create-error-log")
    @ResponseBody
    public String create() {
        return "ok";
    }
}
